package jmine.tec.aom.domain.impl;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;

import jmine.tec.aom.builder.PropertyBuilder;
import jmine.tec.aom.domain.AbstractPropertizedTest;
import jmine.tec.aom.domain.AbstractPropertyValue;
import jmine.tec.aom.domain.Propertized;
import jmine.tec.aom.domain.Property;
import jmine.tec.aom.util.BasePropertyHandler;
import jmine.tec.test.junit4.DBEnv;

import org.junit.Before;

/**
 * @author jrenaut
 */
@DBEnv(refdb = "jmine-tec-aom-db-test.xml", spring = "jmine-tec-aom-test.xml")
public class AbstractPropertizedShould extends AbstractPropertizedTest {

    private Property p1;

    private Property p2;

    @Before
    public void createProperties() {
        this.p1 = PropertyBuilder.aProperty().withMnemonic("p1").save();
        this.p2 = PropertyBuilder.aProperty().withMnemonic("p2").save();
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Propertized getPropertized() {
        return new AbstractPropertized() {
            @Override
            protected Propertized doGetPropertyHandler() {
                return new BasePropertyHandler(new HashSet<Property>(AbstractPropertizedShould.this.getExpectedDynamicProperties()),
                        new HashSet<AbstractPropertyValue<?>>());
            }
        };
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Collection<Property> getExpectedDynamicProperties() {
        return Arrays.asList(this.p1, this.p2);
    }

    /**
     * {@inheritDoc}
     */
    @Override
    protected Collection<Property> getExpectedSyntheticProperties() {
        return Collections.emptyList();
    }

}
